package com.sg.service.biz.pbff.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.pbff.req.*;
import com.sg.dto.biz.pbff.res.*;
import com.sg.dto.integration.component.StepDto;
import com.sg.service.biz.pbff.OffStateService;
import com.wicket.okrapp.integration.OffStateService;
import com.wicket.okrapp.integration.dto.*;
import com.wicket.okrcomponent.integration.OffStateService;
import com.wicket.okrcomponent.integration.dto.*;
import com.wicket.okrframework.integration.AppSceneService;
import com.wicket.okrframework.integration.InductionRecordService;
import com.wicket.okrframework.integration.dto.*;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class OffStateServiceImpl implements OffStateService {

    @Resource
    com.sg.service.biz.component.OffStateService fwCompOffStateClient;
    @Resource
    com.sg.service.biz.framework.InductionRecordService fwBaseInductionRecordClient;
    @Resource
    com.sg.service.biz.app.OffStateService fwAppOffStateClient;
    @Resource
    com.sg.service.biz.framework.AppSceneService fwBaseAppSceneClient;
    @Resource
    private RedisUtil redisUtil;

    /**
     * B2-9查询步骤列表（平台）[873]
     * gen by moon at 8/10/2022, 3:42:30 AM
     */
    @Trace(operationName = "B2-9查询步骤列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryStepListRespDto queryStepList(BffQueryStepListReqDto reqDto) {


        QueryStepListComRespDto queryStepListComRespDto_1 = null;
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto_1 = null;
//步骤0: D2-9查步骤列表(公共) - queryStepListCom
        QueryStepListComRespDto queryStepListComRespDto = null;
        QueryStepListComReqDto queryStepListComReqDto = new QueryStepListComReqDto();
        if (reqDto != null) {
            queryStepListComReqDto.setBizSceneId(reqDto.getBizSceneId());//sourceId:31491_1
            queryStepListComReqDto.setStepName(reqDto.getStepName());//sourceId:31492_1
            queryStepListComReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:31493_1
        }

        /*D2-9查步骤列表(公共)[872]   */
        Assert.isNull(queryStepListComReqDto.getBizSceneId(), "B2-9查询步骤列表（平台）-D2-9查步骤列表(公共)-用于业务场景ID不能为空", false);
        Assert.isNull(queryStepListComReqDto.getIsArchive(), "B2-9查询步骤列表（平台）-D2-9查步骤列表(公共)-是否存档不能为空", false);
        queryStepListComRespDto = fwCompOffStateClient.queryStepListCom(queryStepListComReqDto).getData();

        queryStepListComRespDto_1 = queryStepListComRespDto;

//步骤1: D1-3批量查询就职记录列表（公共） - batchQueryInductionRecordListCom
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto = null;
        if (queryStepListComRespDto != null) {
            BatchQueryInductionRecordListComReqDto batchQueryInductionRecordListComReqDto = new BatchQueryInductionRecordListComReqDto();
            if (queryStepListComRespDto != null) {
                batchQueryInductionRecordListComReqDto.setPerOrgInductionRecordList(queryStepListComRespDto.getStepList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));//sourceId:16774_1
            }

            /*D1-3批量查询就职记录列表（公共）[602]   */

            batchQueryInductionRecordListComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordListCom(batchQueryInductionRecordListComReqDto).getData();

            batchQueryInductionRecordListComRespDto_1 = batchQueryInductionRecordListComRespDto;
        }

        BffQueryStepListRespDto retData = new BffQueryStepListRespDto();
        //数据集融合
        if (queryStepListComRespDto_1 != null && !CollectionUtil.isEmpty(queryStepListComRespDto_1.getStepList())) {
            for (StepDto stepDto : queryStepListComRespDto_1.getStepList()) {
                BffStepDto retElm = new BffStepDto();
                if (queryStepListComRespDto_1 != null) {
                    retElm.setAssistStepId(stepDto.getAssistStepId());//sourceId:13848_2
                    retElm.setStepName(stepDto.getStepName());//sourceId:13851_2
                    retElm.setStepNameCode(stepDto.getStepNameCode());//sourceId:13852_2
                    retElm.setOrderNumber(stepDto.getOrderNumber());//sourceId:13853_2
                    retElm.setSubjectLifeCycle(stepDto.getSubjectLifeCycle());//sourceId:13854_2
                    retElm.setOperationInductionId(stepDto.getOperationInductionId());//sourceId:13855_2
                    retElm.setOperateTime(stepDto.getOperateTime());//sourceId:13856_2
                }
                retData.getStepList().add(retElm);
                if (batchQueryInductionRecordListComRespDto_1 != null) {
                    for (PerOrgInductionRecordDto perOrgInductionRecordDto : batchQueryInductionRecordListComRespDto_1.getPerOrgInductionRecordList()) {
                        if (perOrgInductionRecordDto.getInductionRecordId().equals(stepDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordListComRespDto_1 != null) {
                                retElm.setUserId(perOrgInductionRecordDto.getUserId());//sourceId:38858_2
                                retElm.setUserFace(perOrgInductionRecordDto.getUserFace());//sourceId:38861_2
                                retElm.setIdCardName(perOrgInductionRecordDto.getIdCardName());//sourceId:38859_2
                                retElm.setNickName(perOrgInductionRecordDto.getNickName());//sourceId:38860_2
                            }
                        }
                    }
                }

            }
        }//sourceId:31498_1


        retData.setPageNum(queryStepListComRespDto.getPageNum());
        retData.setPageSize(queryStepListComRespDto.getPageSize());
        retData.setTotal(queryStepListComRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryStepListComRespDto.getTotalNum()) / Double.valueOf(queryStepListComRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B3-11修改检查项（平台）[894]
     * gen by moon at 11/15/2022, 11:38:15 PM
     */
    @Trace(operationName = "B3-11修改检查项（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateCheckItemRespDto updateCheckItem(BffUpdateCheckItemReqDto reqDto) {


        //步骤0: D3-11修改检查项 - updateCheckItem
        UpdateCheckItemRespDto updateCheckItemRespDto = null;
        UpdateCheckItemReqDto updateCheckItemReqDto = new UpdateCheckItemReqDto();
        if (reqDto != null) {
            updateCheckItemReqDto.setCheckItemId(reqDto.getCheckItemId());//SimpleFieldAssign//sourceId:19270_1
            updateCheckItemReqDto.setCheckItemCode(reqDto.getCheckItemCode());//SimpleFieldAssign//sourceId:19271_1
            updateCheckItemReqDto.setCheckItemName(reqDto.getCheckItemName());//SimpleFieldAssign//sourceId:19274_1
            updateCheckItemReqDto.setOrderNumber(reqDto.getOrderNumber());//SimpleFieldAssign//sourceId:437720_1
            updateCheckItemReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:19275_1
        }

        /*D3-11修改检查项[896]   */
        Assert.isNull(updateCheckItemReqDto.getCheckItemId(), "B3-11修改检查项（平台）-D3-11修改检查项-检查项ID不能为空", false);
        updateCheckItemRespDto = fwAppOffStateClient.updateCheckItem(updateCheckItemReqDto).getData();


        BffUpdateCheckItemRespDto retData = new BffUpdateCheckItemRespDto();


        return retData;
    }

    /**
     * B3-11新增检查项（平台）[893]
     * gen by moon at 11/15/2022, 11:38:13 PM
     */
    @Trace(operationName = "B3-11新增检查项（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddCheckItemRespDto addCheckItem(BffAddCheckItemReqDto reqDto) {


        AddCheckItemRespDto addCheckItemRespDto_1 = null;
//步骤0: D3-11新增检查项 - addCheckItem
        AddCheckItemRespDto addCheckItemRespDto = null;
        AddCheckItemReqDto addCheckItemReqDto = new AddCheckItemReqDto();
        if (reqDto != null) {
            addCheckItemReqDto.setCheckItemCode(reqDto.getCheckItemCode());//SimpleFieldAssign//sourceId:19242_1
            addCheckItemReqDto.setBizSceneId(reqDto.getBizSceneId());//SimpleFieldAssign//sourceId:19243_1
            addCheckItemReqDto.setBizSceneCode(reqDto.getBizSceneCode());//SimpleFieldAssign//sourceId:19244_1
            addCheckItemReqDto.setCheckItemName(reqDto.getCheckItemName());//SimpleFieldAssign//sourceId:19245_1
            addCheckItemReqDto.setOrderNumber(reqDto.getOrderNumber());//SimpleFieldAssign//sourceId:437715_1
            addCheckItemReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:19246_1
        }

        /*D3-11新增检查项[886]   */
        Assert.isNull(addCheckItemReqDto.getCheckItemCode(), "B3-11新增检查项（平台）-D3-11新增检查项-检查项标识不能为空", false);
        Assert.isNull(addCheckItemReqDto.getBizSceneId(), "B3-11新增检查项（平台）-D3-11新增检查项-用于业务场景ID不能为空", false);
        Assert.isNull(addCheckItemReqDto.getBizSceneCode(), "B3-11新增检查项（平台）-D3-11新增检查项-业务场景编码不能为空", false);
        Assert.isNull(addCheckItemReqDto.getCheckItemName(), "B3-11新增检查项（平台）-D3-11新增检查项-检查项名称 不能为空", false);
        Assert.isNull(addCheckItemReqDto.getOrderNumber(), "B3-11新增检查项（平台）-D3-11新增检查项-排序不能为空", false);
        Assert.isNull(addCheckItemReqDto.getSubjectLifeCycle(), "B3-11新增检查项（平台）-D3-11新增检查项-主体生命周期不能为空", false);
        addCheckItemRespDto = fwAppOffStateClient.addCheckItem(addCheckItemReqDto).getData();


        addCheckItemRespDto_1 = addCheckItemRespDto;

        BffAddCheckItemRespDto retData = new BffAddCheckItemRespDto();
        if (addCheckItemRespDto_1 != null) {
            retData.setCheckItemId(addCheckItemRespDto_1.getCheckItemId());//SimpleFieldAssign//sourceId:34877_1
        }


        return retData;
    }

    /**
     * B3-11查询检查项详情（平台）[891]
     * gen by moon at 8/10/2022, 3:42:47 AM
     */
    @Trace(operationName = "B3-11查询检查项详情（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCheckItemDetailRespDto queryCheckItemDetail(BffQueryCheckItemDetailReqDto reqDto) {


        QueryCheckItemDetailRespDto queryCheckItemDetailRespDto_1 = null;
        QueryBizSceneDetailRespDto queryBizSceneDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D3-11查详情检查项 - queryCheckItemDetail
        QueryCheckItemDetailRespDto queryCheckItemDetailRespDto = null;
        QueryCheckItemDetailReqDto queryCheckItemDetailReqDto = new QueryCheckItemDetailReqDto();
        if (reqDto != null) {
            queryCheckItemDetailReqDto.setCheckItemId(reqDto.getCheckItemId());//sourceId:19383_1
        }

        /*D3-11查详情检查项[887]   */
        Assert.isNull(queryCheckItemDetailReqDto.getCheckItemId(), "B3-11查询检查项详情（平台）-D3-11查详情检查项-检查项ID不能为空", false);
        queryCheckItemDetailRespDto = fwAppOffStateClient.queryCheckItemDetail(queryCheckItemDetailReqDto).getData();

        queryCheckItemDetailRespDto_1 = queryCheckItemDetailRespDto;

//步骤1: D1-1查询业务场景详情 - queryBizSceneDetail
        QueryBizSceneDetailRespDto queryBizSceneDetailRespDto = null;
        if (queryCheckItemDetailRespDto != null) {
            QueryBizSceneDetailReqDto queryBizSceneDetailReqDto = new QueryBizSceneDetailReqDto();
            if (queryCheckItemDetailRespDto != null) {
                queryBizSceneDetailReqDto.setBizSceneId(queryCheckItemDetailRespDto.getBizSceneId());//sourceId:34626_1
            }

            /*D1-1查询业务场景详情[713]   */
            Assert.isNull(queryBizSceneDetailReqDto.getBizSceneId(), "B3-11查询检查项详情（平台）-D1-1查询业务场景详情-业务场景ID不能为空", false);
            queryBizSceneDetailRespDto = fwBaseAppSceneClient.queryBizSceneDetail(queryBizSceneDetailReqDto).getData();

            queryBizSceneDetailRespDto_1 = queryBizSceneDetailRespDto;
        }

//步骤2: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryCheckItemDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryCheckItemDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryCheckItemDetailRespDto.getOperationInductionId());//sourceId:16883_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B3-11查询检查项详情（平台）-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();

            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryCheckItemDetailRespDto retData = new BffQueryCheckItemDetailRespDto();
        if (queryCheckItemDetailRespDto_1 != null) {
            retData.setCheckItemId(queryCheckItemDetailRespDto_1.getCheckItemId());//sourceId:19421_1
            retData.setCheckItemName(queryCheckItemDetailRespDto_1.getCheckItemName());//sourceId:19425_1
            retData.setCheckItemCode(queryCheckItemDetailRespDto_1.getCheckItemCode());//sourceId:19422_1
            retData.setBizSceneId(queryCheckItemDetailRespDto_1.getBizSceneId());//sourceId:19423_1
            retData.setBizSceneCode(queryCheckItemDetailRespDto_1.getBizSceneCode());//sourceId:19424_1
            retData.setSubjectLifeCycle(queryCheckItemDetailRespDto_1.getSubjectLifeCycle());//sourceId:19426_1
            retData.setOperationInductionId(queryCheckItemDetailRespDto_1.getOperationInductionId());//sourceId:19427_1
            retData.setOperateTime(queryCheckItemDetailRespDto_1.getOperateTime());//sourceId:19428_1
        }
        if (queryBizSceneDetailRespDto_1 != null) {
            retData.setBizSceneName(queryBizSceneDetailRespDto_1.getBizSceneName());//sourceId:34652_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setUserId(queryInductionRecordInfoDetailComRespDto_1.getUserId());//sourceId:19430_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//sourceId:19433_1
            retData.setIdCardName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//sourceId:19431_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//sourceId:19432_1
        }


        return retData;
    }

    /**
     * B3-11查询检查项列表（平台）[890]
     * gen by moon at 8/10/2022, 3:42:43 AM
     */
    @Trace(operationName = "B3-11查询检查项列表（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryCheckItemListRespDto queryCheckItemList(BffQueryCheckItemListReqDto reqDto) {


        QueryCheckItemListRespDto queryCheckItemListRespDto_1 = null;
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto_1 = null;
//步骤0: D3-11查列表检查项 - queryCheckItemList
        QueryCheckItemListRespDto queryCheckItemListRespDto = null;
        QueryCheckItemListReqDto queryCheckItemListReqDto = new QueryCheckItemListReqDto();
        if (reqDto != null) {
            queryCheckItemListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:19507_1
            queryCheckItemListReqDto.setCheckItemName(reqDto.getCheckItemName());//sourceId:161114_1
            queryCheckItemListReqDto.setBizSceneId(reqDto.getBizSceneId());//sourceId:32391_1
        }

        /*D3-11查列表检查项[888]   */
        Assert.isNull(queryCheckItemListReqDto.getIsArchive(), "B3-11查询检查项列表（平台）-D3-11查列表检查项-是否存档不能为空", false);
        Assert.isNull(queryCheckItemListReqDto.getBizSceneId(), "B3-11查询检查项列表（平台）-D3-11查列表检查项-用于业务场景ID不能为空", false);
        queryCheckItemListRespDto = fwAppOffStateClient.queryCheckItemList(queryCheckItemListReqDto).getData();

        queryCheckItemListRespDto_1 = queryCheckItemListRespDto;

//步骤1: D1-3批量查询就职记录列表（公共） - batchQueryInductionRecordListCom
        BatchQueryInductionRecordListComRespDto batchQueryInductionRecordListComRespDto = null;
        if (queryCheckItemListRespDto != null) {
            BatchQueryInductionRecordListComReqDto batchQueryInductionRecordListComReqDto = new BatchQueryInductionRecordListComReqDto();
            if (queryCheckItemListRespDto != null) {
                batchQueryInductionRecordListComReqDto.setPerOrgInductionRecordList(queryCheckItemListRespDto.getCheckItemList().stream().map(item -> item.getOperationInductionId())
                        .collect(Collectors.toList()));//sourceId:16934_1
            }

            /*D1-3批量查询就职记录列表（公共）[602]   */

            batchQueryInductionRecordListComRespDto = fwBaseInductionRecordClient.batchQueryInductionRecordListCom(batchQueryInductionRecordListComReqDto).getData();

            batchQueryInductionRecordListComRespDto_1 = batchQueryInductionRecordListComRespDto;
        }

        BffQueryCheckItemListRespDto retData = new BffQueryCheckItemListRespDto();
        //数据集融合
        if (queryCheckItemListRespDto_1 != null && !CollectionUtil.isEmpty(queryCheckItemListRespDto_1.getCheckItemList())) {
            for (CheckItemListDto checkItemListDto : queryCheckItemListRespDto_1.getCheckItemList()) {
                BffCheckItemListDto retElm = new BffCheckItemListDto();
                if (queryCheckItemListRespDto_1 != null) {
                    retElm.setCheckItemId(checkItemListDto.getCheckItemId());//sourceId:7133_2
                    retElm.setCheckItemName(checkItemListDto.getCheckItemName());//sourceId:7137_2
                    retElm.setCheckItemCode(checkItemListDto.getCheckItemCode());//sourceId:7134_2
                    retElm.setSubjectLifeCycle(checkItemListDto.getSubjectLifeCycle());//sourceId:7138_2
                    retElm.setOperationInductionId(checkItemListDto.getOperationInductionId());//sourceId:7140_2
                    retElm.setOperateTime(checkItemListDto.getOperateTime());//sourceId:7141_2
                }
                retData.getCheckItemList().add(retElm);
                if (batchQueryInductionRecordListComRespDto_1 != null) {
                    for (PerOrgInductionRecordDto perOrgInductionRecordDto : batchQueryInductionRecordListComRespDto_1.getPerOrgInductionRecordList()) {
                        if (perOrgInductionRecordDto.getInductionRecordId().equals(checkItemListDto.getOperationInductionId())) {
                            if (batchQueryInductionRecordListComRespDto_1 != null) {
                                retElm.setUserId(perOrgInductionRecordDto.getUserId());//sourceId:38870_2
                                retElm.setUserFace(perOrgInductionRecordDto.getUserFace());//sourceId:38873_2
                                retElm.setIdCardName(perOrgInductionRecordDto.getIdCardName());//sourceId:38871_2
                                retElm.setNickName(perOrgInductionRecordDto.getNickName());//sourceId:38872_2
                            }
                        }
                    }
                }

            }
        }//sourceId:19516_1


        retData.setPageNum(queryCheckItemListRespDto.getPageNum());
        retData.setPageSize(queryCheckItemListRespDto.getPageSize());
        retData.setTotal(queryCheckItemListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryCheckItemListRespDto.getTotalNum()) / Double.valueOf(queryCheckItemListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B2-9修改步骤[876]
     * gen by moon at 8/10/2022, 3:42:41 AM
     */
    @Trace(operationName = "B2-9修改步骤")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdateStepRespDto updateStep(BffUpdateStepReqDto reqDto) {


        //步骤0: D2-9修改步骤 - updateStep
        UpdateStepRespDto updateStepRespDto = null;
        UpdateStepReqDto updateStepReqDto = new UpdateStepReqDto();
        if (reqDto != null) {
            updateStepReqDto.setAssistStepId(reqDto.getAssistStepId());//sourceId:31644_1
            updateStepReqDto.setStepName(reqDto.getStepName());//sourceId:31645_1
            updateStepReqDto.setStepNameCode(reqDto.getStepNameCode());//sourceId:31646_1
            updateStepReqDto.setEditAssistStepName(reqDto.getEditAssistStepName());//sourceId:31647_1
            updateStepReqDto.setChangeAssistStepName(reqDto.getChangeAssistStepName());//sourceId:31648_1
            updateStepReqDto.setOrderNumber(reqDto.getOrderNumber());//sourceId:31649_1
            updateStepReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:31650_1
        }

        /*D2-9修改步骤[869]   */
        Assert.isNull(updateStepReqDto.getAssistStepId(), "B2-9修改步骤-D2-9修改步骤-步骤ID不能为空", false);
        updateStepRespDto = fwCompOffStateClient.updateStep(updateStepReqDto).getData();


        BffUpdateStepRespDto retData = new BffUpdateStepRespDto();


        return retData;
    }

    /**
     * B2-9新增步骤[875]
     * gen by moon at 8/10/2022, 3:42:37 AM
     */
    @Trace(operationName = "B2-9新增步骤")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddStepRespDto addStep(BffAddStepReqDto reqDto) {


        AddStepRespDto addStepRespDto_1 = null;
//步骤0: D2-9新增步骤 - addStep
        AddStepRespDto addStepRespDto = null;
        AddStepReqDto addStepReqDto = new AddStepReqDto();
        if (reqDto != null) {
            addStepReqDto.setBizSceneId(reqDto.getBizSceneId());//sourceId:31082_1
            addStepReqDto.setBizSceneCode(reqDto.getBizSceneCode());//sourceId:31083_1
            addStepReqDto.setStepName(reqDto.getStepName());//sourceId:31085_1
            addStepReqDto.setStepNameCode(reqDto.getStepNameCode());//sourceId:31086_1
            addStepReqDto.setEditAssistStepName(reqDto.getEditAssistStepName());//sourceId:31087_1
            addStepReqDto.setChangeAssistStepName(reqDto.getChangeAssistStepName());//sourceId:31088_1
            addStepReqDto.setOrderNumber(reqDto.getOrderNumber());//sourceId:31089_1
            addStepReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:31090_1
        }

        /*D2-9新增步骤[870]   */
        Assert.isNull(addStepReqDto.getBizSceneId(), "B2-9新增步骤-D2-9新增步骤-用于业务场景ID不能为空", false);
        Assert.isNull(addStepReqDto.getBizSceneCode(), "B2-9新增步骤-D2-9新增步骤-业务场景标识不能为空", false);
        Assert.isNull(addStepReqDto.getStepName(), "B2-9新增步骤-D2-9新增步骤-步骤名称不能为空", false);
        Assert.isNull(addStepReqDto.getStepNameCode(), "B2-9新增步骤-D2-9新增步骤-步骤编码不能为空", false);
        Assert.isNull(addStepReqDto.getEditAssistStepName(), "B2-9新增步骤-D2-9新增步骤-编辑下“下一步”名称不能为空", false);
        Assert.isNull(addStepReqDto.getChangeAssistStepName(), "B2-9新增步骤-D2-9新增步骤-修订下“下一步”名称不能为空", false);
        Assert.isNull(addStepReqDto.getOrderNumber(), "B2-9新增步骤-D2-9新增步骤-排序不能为空", false);
        Assert.isNull(addStepReqDto.getSubjectLifeCycle(), "B2-9新增步骤-D2-9新增步骤-主体生命周期不能为空", false);
        addStepRespDto = fwCompOffStateClient.addStep(addStepReqDto).getData();

        addStepRespDto_1 = addStepRespDto;

        BffAddStepRespDto retData = new BffAddStepRespDto();
        if (addStepRespDto_1 != null) {
            retData.setAssistStepId(addStepRespDto_1.getAssistStepId());//sourceId:31091_1
        }


        return retData;
    }

    /**
     * B2-9查询步骤详情（平台）[874]
     * gen by moon at 8/10/2022, 3:42:34 AM
     */
    @Trace(operationName = "B2-9查询步骤详情（平台）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryStepDetailRespDto queryStepDetail(BffQueryStepDetailReqDto reqDto) {


        QueryStepDetailRespDto queryStepDetailRespDto_1 = null;
        QueryBizSceneDetailRespDto queryBizSceneDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D2-9查询步骤详情 - queryStepDetail
        QueryStepDetailRespDto queryStepDetailRespDto = null;
        QueryStepDetailReqDto queryStepDetailReqDto = new QueryStepDetailReqDto();
        if (reqDto != null) {
            queryStepDetailReqDto.setAssistStepId(reqDto.getAssistStepId());//sourceId:31560_1
        }

        /*D2-9查询步骤详情[871]   */

        queryStepDetailRespDto = fwCompOffStateClient.queryStepDetail(queryStepDetailReqDto).getData();

        queryStepDetailRespDto_1 = queryStepDetailRespDto;

//步骤1: D1-1查询业务场景详情 - queryBizSceneDetail
        QueryBizSceneDetailRespDto queryBizSceneDetailRespDto = null;
        if (queryStepDetailRespDto != null) {
            QueryBizSceneDetailReqDto queryBizSceneDetailReqDto = new QueryBizSceneDetailReqDto();
            if (queryStepDetailRespDto != null) {
                queryBizSceneDetailReqDto.setBizSceneId(queryStepDetailRespDto.getBizSceneId());//sourceId:34617_1
            }

            /*D1-1查询业务场景详情[713]   */

            queryBizSceneDetailRespDto = fwBaseAppSceneClient.queryBizSceneDetail(queryBizSceneDetailReqDto).getData();

            queryBizSceneDetailRespDto_1 = queryBizSceneDetailRespDto;
        }

//步骤2: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryStepDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryStepDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryStepDetailRespDto.getOperationInductionId());//sourceId:16768_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B2-9查询步骤详情（平台）-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();

            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryStepDetailRespDto retData = new BffQueryStepDetailRespDto();
        if (queryStepDetailRespDto_1 != null) {
            retData.setAssistStepId(queryStepDetailRespDto_1.getAssistStepId());//sourceId:31574_1
            retData.setBizSceneId(queryStepDetailRespDto_1.getBizSceneId());//sourceId:31575_1
            retData.setStepName(queryStepDetailRespDto_1.getStepName());//sourceId:31577_1
            retData.setStepNameCode(queryStepDetailRespDto_1.getStepNameCode());//sourceId:31578_1
            retData.setEditAssistStepName(queryStepDetailRespDto_1.getEditAssistStepName());//sourceId:31579_1
            retData.setChangeAssistStepName(queryStepDetailRespDto_1.getChangeAssistStepName());//sourceId:31580_1
            retData.setOrderNumber(queryStepDetailRespDto_1.getOrderNumber());//sourceId:31581_1
            retData.setSubjectLifeCycle(queryStepDetailRespDto_1.getSubjectLifeCycle());//sourceId:31582_1
            retData.setOperationInductionId(queryStepDetailRespDto_1.getOperationInductionId());//sourceId:31584_1
            retData.setOperateTime(queryStepDetailRespDto_1.getOperateTime());//sourceId:31585_1
        }
        if (queryBizSceneDetailRespDto_1 != null) {
            retData.setBizSceneName(queryBizSceneDetailRespDto_1.getBizSceneName());//sourceId:34621_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setUserId(queryInductionRecordInfoDetailComRespDto_1.getUserId());//sourceId:31587_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//sourceId:31590_1
            retData.setIdCardName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//sourceId:31588_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//sourceId:31589_1
        }


        return retData;
    }

    /**
     * B3查询融合目标检查项父子状态列表(管理)[4961]
     * gen by moon at 10/20/2022, 10:07:02 AM
     */
    @Trace(operationName = "B3查询融合目标检查项父子状态列表(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryFuseTargetCheckItemNodeStatusListRespDto queryFuseTargetCheckItemNodeStatusList(BffQueryFuseTargetCheckItemNodeStatusListReqDto reqDto) {


        QueryFuseTargetCheckItemNodeStatusListRespDto queryFuseTargetCheckItemNodeStatusListRespDto_1 = null;
        ImplementCheckItemRespDto implementCheckItemRespDto_1 = null;
//步骤0: D3查询融合目标检查项父子状态列表 - queryFuseTargetCheckItemNodeStatusList
        QueryFuseTargetCheckItemNodeStatusListRespDto queryFuseTargetCheckItemNodeStatusListRespDto = null;
        QueryFuseTargetCheckItemNodeStatusListReqDto queryFuseTargetCheckItemNodeStatusListReqDto = new QueryFuseTargetCheckItemNodeStatusListReqDto();
        if (reqDto != null) {
            queryFuseTargetCheckItemNodeStatusListReqDto.setEntityId(reqDto.getEntityId());//SimpleFieldAssign//sourceId:383968_1
        }

        /*D3查询融合目标检查项父子状态列表[4962]   */
        Assert.isNull(queryFuseTargetCheckItemNodeStatusListReqDto.getEntityId(), "B3查询融合目标检查项父子状态列表(管理)-D3查询融合目标检查项父子状态列表-目标ID不能为空", false);
        queryFuseTargetCheckItemNodeStatusListRespDto = fwAppOffStateClient.queryFuseTargetCheckItemNodeStatusList(queryFuseTargetCheckItemNodeStatusListReqDto).getData();


        queryFuseTargetCheckItemNodeStatusListRespDto_1 = queryFuseTargetCheckItemNodeStatusListRespDto;

//步骤1: D3-11批量查询检查项 - batchQueryCheckItem
        BatchQueryCheckItemRespDto batchQueryCheckItemRespDto = null;
        if (queryFuseTargetCheckItemNodeStatusListRespDto != null) {
            BatchQueryCheckItemReqDto batchQueryCheckItemReqDto = new BatchQueryCheckItemReqDto();
            batchQueryCheckItemReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:383936_1
            if (queryFuseTargetCheckItemNodeStatusListRespDto != null) {
                batchQueryCheckItemReqDto.setCheckItemList(queryFuseTargetCheckItemNodeStatusListRespDto.getBizAppCheckItemStatList().stream().map(item -> item.getCheckItemCode())
                        .collect(Collectors.toList()));/*list-to-strings*///sourceId:383935_1
            }

            /*D3-11批量查询检查项[3978]   */
            Assert.isNull(batchQueryCheckItemReqDto.getSubjectLifeCycle(), "B3查询融合目标检查项父子状态列表(管理)-D3-11批量查询检查项-主体生命周期不能为空", false);
            batchQueryCheckItemRespDto = fwAppOffStateClient.batchQueryCheckItem(batchQueryCheckItemReqDto).getData();


        }

//步骤2: D3执行检查项 - implementCheckItem
        ImplementCheckItemRespDto implementCheckItemRespDto = null;
        if (queryFuseTargetCheckItemNodeStatusListRespDto != null) {
            ImplementCheckItemReqDto implementCheckItemReqDto = new ImplementCheckItemReqDto();
            if (queryFuseTargetCheckItemNodeStatusListRespDto != null && queryFuseTargetCheckItemNodeStatusListRespDto.getBizAppCheckItemStatList() != null && !CollectionUtil.isEmpty(queryFuseTargetCheckItemNodeStatusListRespDto.getBizAppCheckItemStatList())) {
                implementCheckItemReqDto.setBizAppCheckItemStatList(queryFuseTargetCheckItemNodeStatusListRespDto.getBizAppCheckItemStatList().stream().map(item -> BeanUtil.toBean(item, BizAppCheckItemStatDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:384219_1
            }
            if (batchQueryCheckItemRespDto != null && batchQueryCheckItemRespDto.getCheckItemList() != null && !CollectionUtil.isEmpty(batchQueryCheckItemRespDto.getCheckItemList())) {
                implementCheckItemReqDto.setCheckItemFusionMainContentList(batchQueryCheckItemRespDto.getCheckItemList().stream().map(item -> BeanUtil.toBean(item, CheckItemFusionMainContentDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:384218_1
            }

            /*D3执行检查项[4970]   */

            implementCheckItemRespDto = fwAppOffStateClient.implementCheckItem(implementCheckItemReqDto).getData();


            implementCheckItemRespDto_1 = implementCheckItemRespDto;
        }

        BffQueryFuseTargetCheckItemNodeStatusListRespDto retData = new BffQueryFuseTargetCheckItemNodeStatusListRespDto();
        if (queryFuseTargetCheckItemNodeStatusListRespDto_1 != null) {
            retData.setTargetCheckItemStatusList(queryFuseTargetCheckItemNodeStatusListRespDto_1.getSetConstructionTaskList().stream().map(item -> BeanUtil.toBean(item, BffTargetCheckItemStatusDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:384017_1
        }
        if (implementCheckItemRespDto_1 != null) {
            retData.setTargetNodeStatusList(implementCheckItemRespDto_1.getBizAppCheckItemStatList().stream().map(item -> BeanUtil.toBean(item, BffTargetNodeStatusDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:384221_1
        }


        return retData;
    }
    //
}
